package cn.tansanqinger.DesignMode.Singleton;
class Message3{
    private Message3(){
        System.out.println("构造方法");
    }
    private static Message3 message3 = null;
    public static Message3 getInstance(){
        if(message3==null){
            synchronized (Message3.class){
                if(message3==null){
                    message3 = new Message3();
                }
            }
        }
        return message3;
    }
    public void printf(){
        System.out.println("C3H2");
    }
}
public class ThreadSingleton {
    public static void main(String[] args) {
        for(int i = 0 ; i < 5 ; i ++){
            new Thread(()->{
                Message3 message3 = Message3.getInstance();
                message3.printf();
            }).start();
        }
    }
}
